from selenium.webdriver.common.by import By
from time import sleep

class Loan():

    def __init__(self, driver):
        self.driver = driver

    def loan(self, loan, time):
        # 点击金融工具
        self.driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[3]/a').click()
        # 点击安全网贷
        self.driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[3]/ul/li[2]/a').click()
        # 输入贷款金额
        self.driver.find_element(By.ID, 'amount').send_keys(loan)
        # 输入贷款期限/天
        self.driver.find_element(By.ID, 'term').send_keys(time)
        # 点击申请
        self.driver.find_element(By.ID, 'submit').click()
        # 点击确认
        sleep(0.5)
        self.driver.find_element(By.XPATH, '/html/body/div[2]/div[2]/div/div/div/div/div/div/div/div[4]/button[1]').click()
